package com.aizuda.boot.modules.business.counterparty.controller;


import com.aizuda.boot.modules.business.contract.dto.SingleResponse;
import com.aizuda.boot.modules.common.constant.enums.ResponseCodeEnum;
import com.aizuda.boot.modules.business.counterparty.entity.dto.CreateBankInfoReqDTO;
import com.aizuda.boot.modules.business.counterparty.entity.vo.CreateBankInfoRespDTO;
import com.aizuda.boot.modules.business.counterparty.service.BankInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 银行信息控制器
 */
@Slf4j
@RestController
@RequestMapping("/bank")
@Tag(description = "/bank", name = "银行信息接口")
@Validated
public class BankController {
    
    @Resource
    private BankInfoService bankInfoService;
    
    @PostMapping("/create")
    @Operation(summary = "新增银行信息")
    public SingleResponse<CreateBankInfoRespDTO> createBankInfo(@RequestBody @Valid CreateBankInfoReqDTO reqDTO) {
        try {
            log.info("新增银行信息，请求参数：{}", reqDTO);
            CreateBankInfoRespDTO result = bankInfoService.createBankInfo(reqDTO);
            return SingleResponse.of(result);
        } catch (Exception e) {
            log.error("新增银行信息失败", e);
            return SingleResponse.failure(ResponseCodeEnum.SHOW_MSG.getCode(), "新增银行信息失败: " + e.getMessage());
        }
    }
} 